package com.rockontrol.ele.service.model.dbtransaction.impl;

import com.rksp.svc.BaseSvc;
import com.rockontrol.ele.pojo.Ma材料加工单;
import com.rockontrol.ele.pojo.Ma材料加工单明细;
import com.rockontrol.ele.pojo.Ma综合物品;
import com.rockontrol.ele.service.model.dbtransaction.MaOtherTrans;

public class MaOtherTransImpl extends BaseSvc implements MaOtherTrans{

	public String serviceCreateTheMaterialMachining(Ma材料加工单 mm_) {
		service.addObj(mm_);
		if(mm_.getDetailList()!=null){
			for(Ma材料加工单明细 ma材料加工单明细:mm_.getDetailList()){
				ma材料加工单明细.set加工单id(mm_.getOid());
				service.addObj(ma材料加工单明细);
			}
		}
		return mm_.getOid();
	}

	public Boolean serviceDeleteTheMaterialMachining(String id_) {
		service.execHQL("delete from Ma材料加工单明细 a where a.加工单id='"+id_+"'");
		try {
			service.removeObj(Ma材料加工单.class, id_);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return true;
	}

	public Boolean serviceUpdateTheMaterialMachining(Ma材料加工单 mm_) {
		service.modifyObj(mm_);
		service.execHQL("delete from Ma材料加工单明细 a where a.加工单id='"+mm_.getOid()+"'");
		if(mm_.getDetailList()!=null){
			for(Ma材料加工单明细 ma材料加工单明细:mm_.getDetailList()){
				ma材料加工单明细.set加工单id(mm_.getOid());
				service.addObj(ma材料加工单明细);
			}
		}
		return true;
	}


}
